<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="styles/styles.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Dosis' rel='stylesheet' type='text/css'>
<title>Choose Test</title>
</head>
<body>
<?php 
////////////////////////////////////////////////////////////////////////////////////////
//																				   SETUP
////////////////////////////////////////////////////////////////////////////////////////
require_once('functions.php');
////////////////////////////////////////////////////////////////////////////////////////
//																		GET STUDENT INFO
////////////////////////////////////////////////////////////////////////////////////////
$getStudent = getStudent();
////////////////////////////////////////////////////////////////////////////////////////
//												HANDLE TEST CHOICE AND STOP > 2 ATTEMPTS 
////////////////////////////////////////////////////////////////////////////////////////
$maxTestErr = "";
if (isset($_POST['standardTest'])){	
$con = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);   
$query = "SELECT finalScore FROM studentintest WHERE testID = "
. "'" . $testID . "'"
.  " AND studentID =" 
. "'".  $_SESSION['studentID'] . "'";
$result = mysqli_query($con, $query);
$numberOfRows = mysqli_num_rows($result);
if ($numberOfRows > 0) {
	$maxTestErr = "You have taken all of the attempts you are permitted";	
}
			else
		{
	$_SESSION['attempt'] = 1;
	echo " 1st attempt";	
	header('LOCATION: test.php');			
	} 
}

if (isset($_POST['standardTestRetake'])) // STANDARD TEST RETAKE SELECTED
{
$con = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);   
$query = "SELECT finalScore FROM studentintest WHERE testID = "
. "'" . $testID . "'"
.  " AND studentID =" 
. "'".  $_SESSION['studentID'] . "'";

$result = mysqli_query($con, $query);
$numberOfRows = mysqli_num_rows($result);
if ($numberOfRows == 1) {
	$_SESSION['attempt'] = 2;
	header('LOCATION: test.php');	
		}
		elseif ($numberOfRows > 1)
				{
echo "<p class='crying'>You have taken all of the attempts you are permitted</p>";	
					}
		else
				{
echo "<p class='crying'>You have taken all of the attempts you are permitted</p>";	

	}

}



if (isset($_POST['branchingTest']))
{
header('LOCATION: branchingTest.php');
} 
?>
<header><div id="login right">Logged in as: <?php echo$_SESSION['firstName'];?>.</div>
</header>
<nav>
<?php include 'nav.php' ?>
</nav>
<div id="container" class="one-edge-shadow">
  <div id="mainContent">
    <?php echo "<h2>So {$_SESSION['firstName']}, what would you like to do?</h2>";     
?>
    <div class="selectBox half left ">
      <p>In the standard assessment you will answer questions in a linear fashion that will take you from 1 to 10.</p>
      <p><b>Number of attempts allowed: 2</b></p>
      <form method="post"><input type="submit" id="standardTest" name="standardTest" value="Take Standard Test"  class="btn centre" /></form> <span class="error">
        <?php echo $maxTestErr;?>
        </span>
     </form method="post"> <input type="submit" id="standardTestRetake" name="standardTestRetake" value="Standard Test Retake" class="btn"  /><form>
    </div>
    <div class="half selectBox right">
      <p>In this assessment, questions will be presented to you based on the knowledge that you have shown. Should you get more than 3 questions wrong or 3 questions right, the assessment will become easier or harder to more closely match your knowledge level.</p>
      <p><b>Number of attempts allowed: Unlimited</b></p>
  <form>    <input type="submit" id="branchingTest" name="branchingTest" value=" Take Branching Test" class="btn centre"  /></form>

  </div>
  </div>
</div>


</body>
</html>
